package com.sws.device.config;

import com.sws.common.utils.access_tokenutil.util.AccessTokenUtil;
import com.sws.device.mapper.DevDeviceMapper;
import com.sws.device.service.DeviceIpResolverService;
import com.sws.device.util.DeviceUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * 设备模块自动配置类
 * 用于将设备模块的组件暴露给其他模块使用
 */
@Configuration
@ComponentScan(basePackages = {"com.sws.device.service", "com.sws.device.util"})
@MapperScan(basePackages = {"com.sws.device.mapper"}, sqlSessionFactoryRef = "sqlSessionFactory")
public class DeviceAutoConfiguration {

    /**
     * 设备IP解析器服务
     * 
     * @param devDeviceMapper 设备Mapper
     * @return 设备IP解析器服务
     */
    @Bean
    @ConditionalOnMissingBean
    public DeviceIpResolverService deviceIpResolverService(DevDeviceMapper devDeviceMapper) {
        return new DeviceIpResolverService();
    }
    
    /**
     * 设备工具类
     * 
     * @param devDeviceMapper 设备Mapper
     * @return 设备工具类
     */
    @Bean
    @ConditionalOnMissingBean
    public DeviceUtil deviceUtil(DevDeviceMapper devDeviceMapper) {
        DeviceUtil deviceUtil = new DeviceUtil();
        deviceUtil.setDevDeviceMapper(devDeviceMapper);
        return deviceUtil;
    }
} 